package a66weding.com.jiehuntong.pager;

import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.widgets.CircularImage;
import a66weding.com.jiehuntong.widgets.MarqueeText;
import a66weding.com.jiehuntong.widgets.RoundProgressBar;
import a66weding.com.jiehuntong.widgets.RoundProgressBarDate;

/**
 * Created by admin on 2016/6/22.
 */
public class Diy_findFriendPager extends BasePager implements View.OnClickListener {

    private View mbodyView;
    private RoundProgressBar mRoundProgressBar1;
    private RoundProgressBarDate mRoundProgressBar2;
    private int progress = 0;
    private CircularImage cover_user_photo;
    private MarqueeText tv_marqueeText;
    private ImageView iv_back;

    public Diy_findFriendPager(Activity activity) {
        super(activity);
    }

    @Override
    protected View getView() {
        mbodyView = View.inflate(mActivity, R.layout.activity_diy_findfriend, null);
        mRoundProgressBar1 = (RoundProgressBar) mbodyView.findViewById(R.id.roundProgressBar1);
        mRoundProgressBar2 = (RoundProgressBarDate) mbodyView.findViewById(R.id.roundProgressBar2);
        tv_marqueeText = (MarqueeText) mbodyView.findViewById(R.id.MarqueeText_tv);
        iv_back = (ImageView) mbodyView.findViewById(R.id.back_iv);

        cover_user_photo = (CircularImage) mbodyView.findViewById(R.id.cover_user_photo);
        cover_user_photo.setImageResource(R.mipmap.touxiang);
        myProgressBar();
        return mbodyView;
    }

    private void myProgressBar() {
        new Thread(new Runnable() {

            @Override
            public void run() {
                while (progress <= 70) {
                    progress += 3;
                    System.out.println(progress);
                    mRoundProgressBar1.setProgress(progress);
                    mRoundProgressBar2.setProgress(progress);
                    try {
                        Thread.sleep(100);
                        start(mbodyView);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
    }

    public void start(View v) {
        tv_marqueeText.startScroll();
    }

    public void stop(View v) {
        tv_marqueeText.stopScroll();
    }

    public void startFor0(View v) {
        tv_marqueeText.startFor0();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back_iv:
                mActivity.finish();
                stop(mbodyView);
                break;
        }
    }
}
